package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	SellOrderEventNew           = "erp.SellOrderNew"
	SellOrderEventBeforeCreate  = "erp.SellOrderBeforeCreate"
	SellOrderEventBeforeUpdate  = "erp.SellOrderBeforeUpdate"
	SellOrderEventBeforeSave    = "erp.SellOrderBeforeCreate erp.SellOrderBeforeUpdate"
	SellOrderEventAfterCreate   = "erp.SellOrderAfterCreate"
	SellOrderEventAfterUpdate   = "erp.SellOrderAfterUpdate"
	SellOrderEventAfterSave     = "erp.SellOrderAfterCreate erp.SellOrderAfterUpdate"
	SellOrderEventDelete        = "erp.SellOrderDelete"
	SellOrderAccessControlEvent = "erp.SellOrderAccessControl"
)

func GetSellOrderConfig() *mgo.DocConfig {
	return SellOrder_Config
}

var SellOrder_Config *mgo.DocConfig

func init() {
	SellOrder_Config = NewSellOrderConfig()
}
func NewSellOrderConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.SellOrder",
		Fields: []string{
			"sn", "title", "buyer", "buyerName", "taxType", "payType", "payCashType", "deliverType", "deliverAt", "deliver", "contactEmp", "contact", "contactPhone", "num", "money", "status", "isConfirm", "confirmAt", "isCancel", "isLock", "approvalSate", "approvalStage", "formAt", "formEmp", "createEmp", "note", "product",
		},
		RelationFields: []string{
			"buyer", "taxType", "payType", "payCashType", "deliverType", "contactEmp", "status", "formEmp", "createEmp", "product",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"buyer": {
				Config:     GetBuyerConfig,
				DocName:    "Buyer",
				JoinType:   "O",
				KeyInside:  "buyerId",
				KeyOutSide: "id",
			},
			"taxType": {
				Config:     GetTaxTypeConfig,
				DocName:    "TaxType",
				JoinType:   "O",
				KeyInside:  "taxTypeId",
				KeyOutSide: "id",
			},
			"payType": {
				Config:     GetPayTypeConfig,
				DocName:    "PayType",
				JoinType:   "O",
				KeyInside:  "payTypeId",
				KeyOutSide: "id",
			},
			"payCashType": {
				Config:     GetPayCashTypeConfig,
				DocName:    "PayCashType",
				JoinType:   "O",
				KeyInside:  "payCashTypeId",
				KeyOutSide: "id",
			},
			"deliverType": {
				Config:     GetDeliverTypeConfig,
				DocName:    "DeliverType",
				JoinType:   "O",
				KeyInside:  "deliverTypeId",
				KeyOutSide: "id",
			},
			"contactEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "contactEmpId",
				KeyOutSide: "id",
			},
			"status": {
				Config:     GetSellOrderStatusConfig,
				DocName:    "SellOrderStatus",
				JoinType:   "O",
				KeyInside:  "statusId",
				KeyOutSide: "id",
			},
			"formEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "formEmpId",
				KeyOutSide: "id",
			},
			"createEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "createEmpId",
				KeyOutSide: "id",
			},
			"product": {
				Config:     GetSellOrderProductConfig,
				DocName:    "SellOrderProduct",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "belongToId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
